using System.Collections.Generic;
using SkaldRogueLike.Main.CellContent.Items;
using SkaldRogueLike.Main.Common;
using SkaldRogueLike.Main.Constants.Enumerations;

namespace SkaldRogueLike.Main.CellContent.Creatures
{
    public class Character : Creature
    {
        #region Stats
        public int Con { get; protected set; }
        public int Str { get; protected set; }

        private void GenerateStats()
        {
            Con = 10;
            Def = 10;
            Str = 10;
            Att = Str;
            HP = Con * 2;
        }
        #endregion

        private Wardrobe Wardrobe { get; set; }

        public Character(string name, string description = "")
            : base(name, Styles.Character, Colors.White, description)
        {
            GenerateStats();
            Wardrobe = new Wardrobe();
        }
        
        public override int Attack(Creature creature)
        {
            return creature.TakeDamage(Att + Wardrobe.GetEquipmentBonus(Bonus.Att));
        }

        public override int TakeDamage(int attack)
        {
            var damage = attack - (Def + Wardrobe.GetEquipmentBonus(Bonus.Def));
            damage = damage < 1 ? 1 : damage;
            HP -= damage;
            return damage;
        }

        #region Items

        public List<Equipment> GetEquipmentFromBag()
        {
            return Inventory.GetItemsOfTypeEquipmentFromBag();
        }

        public void Equip(Equipment equipment)
        {
            Inventory.UpdateBagAfterEquipping(equipment, Wardrobe.Equip(equipment));
        }

        public void Unequip(Equipment equipment)
        {
            Wardrobe.Unequip(equipment);
            Inventory.PutInBag(equipment);
        }

        public List<Equipment> ShowEquipped()
        {
            return Wardrobe.ShowEquipped();
        }

        #endregion
    }
}